import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login.vue'
import StuHome from '../components/stu/StuHome.vue'

import HomeDetail from '../components/stu/answer/homework/HomeDetail.vue'
import Homework from '../components/stu/answer/homework/Homework.vue'
import Test from '../components/stu/answer/test/Test.vue'
import TestDetail from '../components/stu/answer/test/TestDetail.vue'

import One from '../components/stu/mirror/One.vue'
import Two from '../components/stu/mirror/Two.vue'
import Three from '../components/stu/mirror/Three.vue'
import Four from '../components/stu/mirror/Four.vue'
import Five from '../components/stu/mirror/Five.vue'
import Six from '../components/stu/mirror/Six.vue'

import HDetail from '../components/stu/score/homework/HDetail.vue'
import Hwork from '../components/stu/score/homework/Hwork.vue'
import Tes from '../components/stu/score/test/Tes.vue'
import TDetail from '../components/stu/score/test/TDetail.vue'
import HContent from '../components/stu/score/homework/HContent.vue'
import TContent from '../components/stu/score/test/TContent.vue'

import Exam from '../components/tea/Exam.vue'
import Questions from '../components/tea/Questions.vue'
import Task from '../components/tea/Task.vue'
import TeaHome from '../components/tea/TeaHome.vue'

import THContent from '../components/tea/score/homework/THContent.vue'
import THDetail from '../components/tea/score/homework/THDetail.vue'
import THwork from '../components/tea/score/homework/THwork.vue'
import TEAContent from '../components/tea/score/test/TEAContent.vue'
import TEADetail from '../components/tea/score/test/TEADetail.vue'
import TEAes from '../components/tea/score/test/TEAes.vue'

import Student from '../components/admin/Student.vue'
import Teacher from '../components/admin/Teacher.vue'
import AdminHome from '../components/admin/AdminHome.vue'
import Developer from '../components/admin/Developer.vue'
import DevDetail from '../components/admin/DevDetail.vue'
import DevDetailshow from '../components/admin/DevDetailshow.vue'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/login', component: Login },
    {
      path: '/stuhome',
      component: StuHome,
      children: [
        { path: '/answer/homedetail/:id', component: HomeDetail },
        { path: '/answer/homework', component: Homework },
        { path: '/answer/test', component: Test },
        { path: '/answer/testdetail/:id', component: TestDetail },
        { path: '/score/hdetail/:id', component: HDetail },
        { path: '/score/hwork', component: Hwork },
        { path: '/score/hcontent/:id', component: HContent },
        { path: '/score/tes', component: Tes },
        { path: '/score/tdetail/:id', component: TDetail },
        { path: '/score/tcontent/:id', component: TContent },
        
        { path: '/stu/one', component: One },
        { path: '/stu/two', component: Two },
        { path: '/stu/three', component: Three },
        { path: '/stu/four', component: Four },
        { path: '/stu/five', component: Five },
        { path: '/stu/six', component: Six },
      ]
    },
    {
      path: '/teahome',
      component: TeaHome,
      children: [
        { path: '/tea/exam', component: Exam },
        { path: '/tea/questions', component: Questions },
        { path: '/tea/task', component: Task },
        { path: '/tea/thwork', component: THwork },
        { path: '/tea/thcontent/:id', component: THContent },
        { path: '/tea/thdetail/:id', component: THDetail },
        { path: '/tea/teaes', component: TEAes },
        { path: '/tea/teacontent/:id', component: TEAContent },
        { path: '/tea/teadetail/:id', component: TEADetail },
      ]
    },
    {
      path: '/adminhome',
      component: AdminHome,
      children: [
        { path: '/admin/student', component: Student },
        { path: '/admin/teacher', component: Teacher }
      ]
    },
    { path: '/admin/developer', component: Developer },
    { path: '/admin/devdetail/:id', component: DevDetail },
    { path: '/admin/devdetailshow/17', component: DevDetailshow }
  ]
})

// router.beforeEach((to, from, next) => {
//   if (to.path === '/login') return next();

//   //获取token
//   const tokenStr = window.sessionStorage.getItem('userId');

//   //无则跳转至登录页面
//   if (!tokenStr) return next('/login');

//   next();
// })

export default router
